home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
6584
/
6584.xpi
/
chrome
/
flashvideodownloader
/
content
/
searchvideo.js
< prev
next >
Wrap
Text File
|
2009-11-29
|
2KB
|
84 lines
var FlashVDSearchVideo = {
init : function() {},
search : function(event)
{
// get user input
var key = document.getElementById('search_key').value;
// trim the string
key = key.replace(/^\s+|\s+$/, '');
// chek input string: if string is empty - tell user
if (key == "")
{
alert('Search string is empty.');
return false;
}
// encode key
key = this.encodeURL(key);
// build url
//var url = "http://start.flashvideodownloader.org/google-video-search-res.php?cx=partner-pub-5087362176467115%3Ah6z8ss-efx2&cof=FORID%3A10&ie=ISO-8859-1&q=" + key + "&sa=Search#1054";
var url = "http://start.flashvideodownloader.org/result.php?q=" + key + "&search&cx=partner-pub-5087362176467115:h6z8ss-efx2&cof=FORID:10&ie=ISO-8859-1&sa=Search#1153";
// get the browser object
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var mainWindow = wm.getMostRecentWindow("navigator:browser");
var browser = mainWindow.getBrowser();
// add new tab with our url
var tab = browser.addTab(url);
// make the tab active
browser.selectedTab = tab;
// close the dialog
window.close();
},
search_if_pressed_enter : function(event) {
if (event.keyCode == 13)//DOM_VK_RETURN)// && !btn_ok.disabled)
{
this.search();
}
},
chek_status : function(event) {
var key = document.getElementById('search_key').value;
var btn_ok = document.getElementById('search');
// trim the string
key = key.replace(/^\s+|\s+$/, '');
// chek input string: if string is empty - disable serach button
btn_ok.disabled = (key == "");
},
encodeURL : function(text) {
var sc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.!~*'()";
var h="0123456789ABCDEF";
var encoded="";
for (var i=0; i < text.length; i++ ) {
var ch=text.charAt(i);
if (ch==" ") {
encoded+="+";
} else if (sc.indexOf(ch) != -1) {
encoded+=ch;
} else {
var charCode=ch.charCodeAt(0);
if (charCode > 255) {
encoded+="+";
} else {
encoded+="%"+h.charAt((charCode >> 4) & 0xF)+h.charAt(charCode & 0xF);
}
}
}
return encoded;
}
} // FlashVDSearchVideo